<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>中国福利彩票</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">

<!--页面样式-->
<link rel="stylesheet" type="text/css" href="css/style.css" />

</head>
<body  style="width:10rem !important; margin:0 auto">
<script>
/*取设备宽度*/
	function rem(){
	var iWidth=document.documentElement.getBoundingClientRect().width;
	iWidth=iWidth>640?640:iWidth;
	document.getElementsByTagName("html")[0].style.fontSize=iWidth/10+"px";
	};
	rem();
	window.onorientationchange=window.onresize=rem      
</script>
<script src="js/jquery-1.7.2.min.js"></script>
<div class="Header">
<!--     	<div style="float:left;" class="left H_logot"><a href="MemberCenter.html"><img src="images/logo.png"></a></div> -->
        <div style="float:left;width:5rem;margin-left:1.4rem" class="left H_content text-center font28 cfffff">注册会员</div>
        <div style="float:right;width:2.2rem" class="right H_right text-right font24"><a href="Login.html">登录</a></div>
        <div class="clear"></div>
    </div>
    
    <div class="Forgetpwd">
    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td colspan="2">
            	<div class="FPWD_li">
                	<dl>
                    	<dt><img src="images/Fimg3.png"></dt>
                        <dd><input type="text" class="DT_text1 font28 c666666 Weiruan" placeholder="姓名" id="name"></dd>
                        <div class="clear"></div>
                    </dl>
                </div>
            </td>
          </tr>
          <tr>
            <td colspan="2">
            	<div class="RG_se">
                	<dl>
                    	<dt class="font28 c999999">
                        	<img src="images/Fimg3.png">性别
                        </dt>
                      <dd>
                        	<select name="" class="RG_opt font28 Weiruan c999999 text-center" id="sex">
                        	  <option value="1">男</option>
                        	  <option value="0">女</option>
                        	</select>
                      </dd>
                        <div class="clear"></div>
                    </dl>
                </div>
            </td>
          </tr>
          <tr>
            <td colspan="2">
            	<div class="FPWD_li">
                	<dl>
                    	<dt><img src="images/Fimg2.png"></dt>
                        <dd><input type="text" class="DT_text1 font28 c666666 Weiruan" placeholder="身份证号" id="idCard"></dd>
                        <div class="clear"></div>
                    </dl>
                </div>
            </td>
          </tr>
          <tr>
            <td>
            	<div class="RG_se1">
                	<dl>
                    	<dt class="font28 c999999">
                        	银行：
                        </dt>
                      <dd>
                        	<select name="" class="RG_opt1 font28 Weiruan c999999 text-center" id="bank">
                        	</select>
                      </dd>
                        <div class="clear"></div>
                    </dl>
                </div>
            </td>
          </tr>
          <tr>
           <td>
            	<div class="RG_se1" style="width:8.1rem;">
                	<dl style="float:left;width:5.1rem">
                    	<dt class="font28 c999999" style="width:1.9rem;">
                        	归属地：
                        </dt>
                      <dd style="float:left;">
                        	<select name="" class="RG_opt2 font28 Weiruan c999999 text-center" id="homeOwnership" >
                        	</select>
                      </dd>
                    </dl>
					<dl style="float:right;width:2.8rem">
						<dd style="float:left;">
						<select name="" class="RG_opt2 font28 Weiruan c999999 text-center" id="homeOwnershipcity">
						</select>
                      </dd>
                        <div class="clear"></div>
					</dl>
                </div>
            </td>
          </tr>
          <tr>
            <td colspan="2">
            	<div class="FPWD_li">
                	<dl>
                    	<dt><img src="images/Fimg4.png"></dt>
                        <dd><input type="text" class="DT_text1 font28 c666666 Weiruan" placeholder="银行卡号" id="bankCard"></dd>
                        <div class="clear"></div>
                    </dl>
                </div>
            </td>
          </tr>
          <tr>
            <td colspan="2"><input type="submit" value="完成注册" class="FPWD_but font32 cfffff Weiruan marginT80"   onclick="nextStep()" /></td>
          </tr>
        </table>
    </div>
    <!-- 弹出alert -->
	<div class="falert" style="display: none;" id="warnInfoDiv">

		<div class="falert_t font30">
			<span style="margin-left: 0.15rem">提示</span>
		</div>
		<div class="falert_b">
			<span id="warnInfo"></span><img class="dianji_gb"
				style="position: absolute; right: 0.1rem; top: 0.15rem; cursor: pointer;"
				width="45rem" src="images/Fimg8.png"
				onclick="closeWarnInfoDiv('warnInfoDiv')" />
		</div>
	</div>
	<!-- 弹出alert -->
</body>
<script src="js/common.js"></script>
<script src="js/jsCallCookies.js"></script>
<script src="js/validation.js"></script>
<script type="text/javascript">
var accountId="";
var token="";
var channelId="";
var password="";
//点击“下一步”执行  
function nextStep() {
	 //验证身份证
	if(!validateIDCard('idCard')){
		return;
	}
	 //验证姓名
	if(!validateName('name')){
		return;
	}
	//验证银行卡号
	if(!validateBankNum('bankCard')){
		return;
	}
  var para = {
		  	bankCard:$('#bankCard').val(),
			regionCode:$('#homeOwnership').val()+"_"+$('#homeOwnershipcity').val(),
			swiftCode:$('#bank').val(),
			name:$('#name').val(),
			idCard:$('#idCard').val(),
			sex:$('#sex').val(),
			accountId:accountId,
			token:token,
			password:password,
			channelId:channelId
        };
	
	$.ajax({
		url : "../../api/accountSystem/register/authentication",
		async:false,
		type : "POST",
		herder:{
			'Accept':'application/json',
			'Content-Type':'application/json'
		},
		dataType:"json",
		contentType:"application/json",
		data: JSON.stringify(para),
		error:function(XMLHttpRequest, textStatus, errorThrown){
			alert(errorThrown);
		},
		success: function(data, textStatus){
			setCookie('username',$('#name').val(),0);
			if(data.success == true){
				window.location.href='Register2.html?type=0';
			}else{
				alert(data.description);
				return;
			}
		}		
	});
} 
$(document).ready(function(){
	accountId = getCookie("accountId");
	token = getCookie("token");
	channelId = getCookie("channelId");
	password = GetQueryString("password");
	//调用接口查询 银行类别
	$.ajax({
		url : "../../api/accountSystem/para/swiftcode",
		async:false,
		type : "GET",
		herder:{
			'Accept':'application/json',
			'Content-Type':'application/json'
		},
		dataType:"json",
		contentType:"application/json",
		error:function(XMLHttpRequest, textStatus, errorThrown){
			alert(errorThrown);
		},
		success: function(data, textStatus){
			document.getElementById("bank").options.length=0;
			for(var i=0;i<data.length;i++){
				document.getElementById("bank").options.add(new Option(data[i].swiftName,data[i].swiftCode));
			}
		}		
	});
	//调用地区参数查询接口
	getFirstLevel();
	getSecondLevel($('#homeOwnership').val());
	
	//归属地第一级改变出发的事件
	$("#homeOwnership").change(function(){
		getSecondLevel($('#homeOwnership').val());
		});
});

//获得归属地--第一级
function getFirstLevel(){
	$.ajax({
		url : "../../api/accountSystem/para/region?pid=0",
		async:false,
		type : "GET",
		herder:{
			'Accept':'application/json',
			'Content-Type':'application/json'
		},
		dataType:"json",
		contentType:"application/json",
		error:function(XMLHttpRequest, textStatus, errorThrown){
			alert(errorThrown);
		},
		success: function(data, textStatus){
			document.getElementById("homeOwnership").options.length=0;
// 			var obj = eval("("+data+")"); 
			for(var i=0;i<data.length;i++){
				document.getElementById("homeOwnership").options.add(new Option(data[i].regionName,data[i].id));
			}
		}		
	});
}
//获得归属地--第二级
function getSecondLevel(pid){
	if(pid==null){
		pid=0;
	}
	$.ajax({
		url : "../../api/accountSystem/para/region?pid="+pid+"",
		async:false,
		type : "GET",
		herder:{
			'Accept':'application/json',
			'Content-Type':'application/json'
		},
		dataType:"json",
		contentType:"application/json",
		error:function(XMLHttpRequest, textStatus, errorThrown){
			alert(errorThrown);
		},
		success: function(data, textStatus){
			document.getElementById("homeOwnershipcity").options.length=0;
// 			var obj = eval("("+data+")"); 
			for(var i=0;i<data.length;i++){
				document.getElementById("homeOwnershipcity").options.add(new Option(data[i].regionName,data[i].id));
			}
		}		
	});
}
</script>
</html>
